using System;
using System.Reflection;
using NBody;
using NBody.Analysis;
using OptionParser;

[assembly: AssemblyTitle ("NBodyImage")]
[assembly: AssemblyVersion ("1.0.*")]
[assembly: AssemblyDescription ("Create a BASIC image from N-body data.")]
[assembly: AssemblyCopyright ("2005 Joseph D. MacMillan")]

public class ImageOptions : InputOutputGetOptions
{
    [Option ("-g", "Number of grid points")]
    public int NumGrid;
    
    [Option ("-axis", "Axis to look down - x, y, or z")]
    public string Axis;
    
    [Option ("-radius", "Only include particles within radius")]
    public double Radius;
    
    public ImageOptions()
    {
        NumGrid = 300;
        Axis = "z";
        Radius = 0.0;
    }
}

public class NBodyImage
{
    public static void Main(string[] args)
    {
        ImageOptions opts = new ImageOptions();
        opts.ProcessArgs(args, ".basic");
                        
        NBodySystem s = NBodySystem.Read(opts.InFile);
        
        if (opts.Radius > 0.0)
            s.ExtractSphere(opts.Radius);
        
        Image image = new Image();
        image.GridPoints = opts.NumGrid;
        Image.ViewerAxis axis;
        // there's a better way of doing this
        if (opts.Axis.ToUpper() == "X")
            axis = Image.ViewerAxis.X;
        else if (opts.Axis.ToUpper() == "Y")
            axis = Image.ViewerAxis.Y;
        else
            axis = Image.ViewerAxis.Z;
        image.Axis = axis;
        
        image.Create(s);
        
        image.WriteBasic(opts.OutFile);
    }
}
